<div id="main">
    <div id="contents">
        <form method="post" action="#" name="filters" id="form1">
            <fieldset>
                <legend>
                    <label sid="wireless_basic.wds_title"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="id2272">
                                    <label sid="wireless_basic.wds_mode"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <select id="id2272" onchange="read();" name="id2272">
                                    <option value="0" sid="wireless_basic.wds_mode_select1"></option>
                                    <option value="4" sid="wireless_basic.wds_mode_select2"></option>
                                    <option value="2" sid="wireless_basic.wds_mode_select3"></option>
                                    <option value="3" sid="wireless_basic.wds_mode_select4"></option>
                                </select>
                            </td>
                        </tr>
                        <tr id="tr2273">
                            <td class="frame_tab_left">
                                <label for="id2273">
                                    <label sid="wireless_basic.wds_encryp_type"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <select id="id2273" name="id2273">
                                    <option value="NONE">NONE</option>
                                    <option value="WEP">WEP</option>
                                    <option value="TKIP">TKIP</option>
                                    <option value="AES">AES</option>
                                </select>
                            </td>
                        </tr>
                        <tr id="tr2275">
                            <td class="frame_tab_left">
                                <label for="id2275">
                                    <label sid="wireless_basic.wds_encryp_key"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2275" type="text" value="" maxlength="64" size="28" name="id2275">
                            </td>
                        </tr>
                        <tr id="wds_mac_list_1">
                            <td class="frame_tab_left">
                                <label for="id2274_0">
                                    <label sid="wireless_basic.wds_ap_macaddr"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2274_0" type="text" value="" maxlength="20" size="20" name="id2274_0">
                                <span class="x-form-tip" id="id2274_0Tip"></span>
                            </td>
                        </tr>
                        <tr id="wds_mac_list_2">
                            <td class="frame_tab_left">
                                <label for="id2274_1">
                                    <label sid="wireless_basic.wds_ap_macaddr"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2274_1" type="text" value="" maxlength="20" size="20" name="id2274_1">
                                <span class="x-form-tip" id="id2274_1Tip"></span>
                            </td>
                        </tr>
                        <tr id="wds_mac_list_3">
                            <td class="frame_tab_left">
                                <label for="id2274_2">
                                    <label sid="wireless_basic.wds_ap_macaddr"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2274_2" type="text" value="" maxlength="20" size="20" name="id2274_2">
                                <span class="x-form-tip" id="id2274_2Tip"></span>
                            </td>
                        </tr>
                        <tr id="wds_mac_list_4">
                            <td class="frame_tab_left">
                                <label for="id2274_3">
                                    <label sid="wireless_basic.wds_ap_macaddr"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                               <input id="id2274_3" type="text" value="" maxlength="20" size="20" name="id2274_3">
                                <span class="x-form-tip" id="id2274_3Tip"></span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input id="submit" class="button" type="button" name="submit" sid="sbutton.save">
                                <span style="padding-left:20px;"></span>
                                <input id="Scanning" class="button" type="button" onclick="load_html();" name="submit" sid="wireless_basic.wds_ap_mac">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset id="wds_ap_mac" style="display:none;'>
		<legend>&#160;<label sid="wireless_basic.wds_ap_mac">&#160;</legend>
		<div class="frame_tab_layer">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cmenutitle" id="mactable">

            </table>
    </div>
    </fieldset>
        </form>
    </div>
</div>
<br>
<div id="helpContainer">
    <div id="help">
        <div>
            <h2>
                <label sid="share.help"></label>
            </h2>
        </div>
        <div id="helpBody">
        <dl>
            <dt class="term">
                <label sid="wireless_basic.wds_title"></label>
            </dt>
            <dd class="definition">
                <label sid="wireless_basic.wds_note1"></label>
            </dd>

            <dt class="term">
                <label sid="wireless_basic.wds_mode_select2"></label>
            </dt>
            <dd class="definition">
                <label sid="wireless_basic.wds_note2"></label>
            </dd>
            <dt class="term">
                <label sid="wireless_basic.wds_mode_select3"></label>
            </dt>
            <dd class="definition">
                <label sid="wireless_basic.wds_note3"></label>
            </dd>
            <dt class="term">
                <label sid="wireless_basic.wds_mode_select4"></label>
            </dt>
            <dd class="definition">
                <label sid="wireless_basic.wds_note4"></label>
            </dd>
            <dd class="definition">
                <label sid="wireless_basic.wds_note5"></label>
            </dd>
        </dl>
        </div>
    </div>
</div>
<script type="text/javascript" src="js/libTable.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#wds_ap_mac").hide();
        var nonames = new Array("submit","id2274_0","id2274_1","id2274_2","id2274_3","Scanning");
        var sendtext = getSendText(nonames);
        sendtext += "&id=2274";
        DataRequest("get_json",sendtext,function(data){
            getResult(nonames,data);
            read();
            var values2274 = data["id2274"];
            getvalue(values2274,"2274");
        });

        $.formValidator.initConfig({formID:"form1",debug:false,submitOnce:true,submitButtonID:"submit",
            onError:function(msg, obj, errorlist) {

            },
            onSuccess:function(){
                $(".errormsg").html('');
                var settext = getSetText(nonames);
                var set2274 = '';
                for(var i=0;i<4;i++){
                    if($("#id2274_"+i).val()!="undefined"&&$("#id2274_"+i).val()!=""){
                        set2274 += $("#id2274_"+i).val()+";";
                    }
                }
                set2274 = set2274.substr(0,set2274.length-1);
                settext+="&id2274="+set2274;
                settext=settext.replace(/\#/g,"%23");
                submitform(modules["set_data"],settext);
            }
        });
        $("#id2274_0").formValidator({
            onFocus:errmsg.Info7
        }).regexValidator({
                    regExp:regexEnum.notempty,
                    onError:errmsg.Info3
                }).regexValidator({
                    regExp:regexEnum.mac,
                    onError:errmsg.Info1
                });
        $("#id2274_1").formValidator({
            onFocus:errmsg.Info7
        }).regexValidator({
                    regExp:regexEnum.notempty,
                    onError:errmsg.Info3
                }).regexValidator({
                    regExp:regexEnum.mac,
                    onError:errmsg.Info1
                });
        $("#id2274_2").formValidator({
            onFocus:errmsg.Info7
        }).regexValidator({
                    regExp:regexEnum.notempty,
                    onError:errmsg.Info3
                }).regexValidator({
                    regExp:regexEnum.mac,
                    onError:errmsg.Info1
                });
        $("#id2274_3").formValidator({
            onFocus:errmsg.Info7
        }).regexValidator({
                    regExp:regexEnum.notempty,
                    onError:errmsg.Info3
                }).regexValidator({
                    regExp:regexEnum.mac,
                    onError:errmsg.Info1
                });
        $("#submit").bind("mouseover",function(){
            for(var i=0;i<4;i++){
                if($("#id2274_"+i).val()==""){
                    $("#id2274_"+i).unFormValidator(true);
                }
            }
        });
        $("#submit").bind("mouseout",function(){
            $("#id2274_0,#id2274_1,#id2274_2,#id2274_3").unFormValidator(false);
        });
    });


    function getvalue(values,id){
        if(values.indexOf(";")>=0){
            var arrays= values.split(";");
            for(var i =0;i<arrays.length;i++){
                updatecfgvalue("id"+id+"_"+i,arrays[i]);
            }
        }else{
            updatecfgvalue("id"+id+"_0",values);
        }
    }

    var virtual_data = new Array();
    var old_virtual=0;

    function load_html(){
        show_message("pro",msg.saving);
        var sendtext = 'status?get&param=WROC_siteSurvey';
        DataRequest("none",sendtext,function(data){
            $("#message_panel").fadeOut();
            $("#lock_div").hide();
            $("#lock_div2").hide();
            $("#message_panel").hide();
            var tmparray = strToJSON(data["siteSurvey"].substr(0,data["siteSurvey"].length-1));
            if(tmparray!=""&&tmparray){
                $("#wds_ap_mac").show();
                virtual_data = tmparray;
                virtual_paint_list(tmparray);
            }
        });
    }

    function virtual_paint_list(data){
        var data_new=new Array();
        var j=0;
        for(var i=0;i<data.length;i++){
            var ID = parseInt(parseInt(i)+1);
            var channel = data[i][0];
            var ssid = data[i][1];
            var bssid = data[i][2];
            var security = data[i][3].replace("WPA1PSKWPA2PSK","WPA1/WPA2-PSK").replace("WPA1PSK","WPA1-PSK").replace("WPA2PSK","WPA2-PSK");
            var modes = data[i][5];
            data_new.push({ID:ID,channel:channel,ssid:ssid,bssid:bssid,security:security,modes:modes});
            j = i;
        }
        var fun_arr = [{type:"add",name:"addmac"}];
        var tab = new libTable(new Array(content.filter_webs_url_fitler_No,wireless_basic.frequency,wireless_basic.ssid,wireless_basic.bssid,secure.security_mode+"/"+secure.wpa_algorithm,wireless_basic.network_mode,msg.op),data_new,1,10);
        print_table("mactable",tab,fun_arr, true);
    }

    function addmac(id,channel,ssid,bssid,security,modes)
    {
        obj = virtual_data[parseInt(id)-1];
        with(obj){
            var flag="";
            for(var i=0;i<4;i++){
                if($("#id2274_"+i).val()==""){
                    $("#id2274_"+i).val(bssid);
                    flag="1";
                    break;
                }
            }
            if(flag==""){
                //show_message("err",msg.addmore);
                alert(msg.addmore);
            }
        }
    }



    function read(){
        if($("[name=id2272]").val()=="0"){
            $("#tr2273").hide();
            $("#tr2275").hide();
            $("#wds_mac_list_1").hide();
            $("#wds_mac_list_2").hide();
            $("#wds_mac_list_3").hide();
            $("#wds_mac_list_4").hide();
            $("#Scanning").hide();
        }else if($("[name=id2272]").val()=="4"){
            $("#tr2273").show();
            $("#tr2275").show();
            $("#wds_mac_list_1").hide();
            $("#wds_mac_list_2").hide();
            $("#wds_mac_list_3").hide();
            $("#wds_mac_list_4").hide();
            $("#Scanning").hide();
        }else if($("[name=id2272]").val()=="2"){
            $("#tr2273").show();
            $("#tr2275").show();
            $("#wds_mac_list_1").show();
            $("#wds_mac_list_2").show();
            $("#wds_mac_list_3").show();
            $("#wds_mac_list_4").show();
            $("#Scanning").show();
        }else if($("[name=id2272]").val()=="3"){
            $("#tr2273").show();
            $("#tr2275").show();
            $("#wds_mac_list_1").show();
            $("#wds_mac_list_2").show();
            $("#wds_mac_list_3").show();
            $("#wds_mac_list_4").show();
            $("#Scanning").show();
        }
    }
</script>

